package kr.hkit.androidcomplete01.ch06;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ParamRelative extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		RelativeLayout relativelayout = new RelativeLayout(this);
		
		TextView chul = new TextView(this);
		chul.setText("철수");
		chul.setTextSize(30);
		chul.setId(1);
		chul.setTextColor(Color.BLUE);
		
		
		RelativeLayout.LayoutParams param1 = new RelativeLayout.LayoutParams
				(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
		param1.setMargins(0, 0, 20, 0);
		relativelayout.addView(chul, param1);
		
		
		
		TextView young = new TextView(this);
		young.setText("영희");
		young.setTextSize(20);
		young.setId(2);
		
		RelativeLayout.LayoutParams param2 = new RelativeLayout.LayoutParams
				(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
		param2.addRule(RelativeLayout.RIGHT_OF, chul.getId());
		relativelayout.addView(young, param2);
		
		
		
		TextView mong = new TextView(this);
		mong.setText("몽룡");
		mong.setTextSize(20);
		mong.setId(3);
		mong.setTextColor(Color.RED);
		
		RelativeLayout.LayoutParams param3 = new RelativeLayout.LayoutParams
				(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
		param3.addRule(RelativeLayout.BELOW, young.getId());
		param3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		param3.setMargins(0, 0, 0, 0);
		relativelayout.addView(mong, param3);
		
		
		
		TextView chun = new TextView(this);
		chun.setText("춘향");
		chun.setTextSize(10);
		chun.setId(4);
		
		RelativeLayout.LayoutParams param4 = new RelativeLayout.LayoutParams
				(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
		param4.addRule(RelativeLayout.LEFT_OF, mong.getId());
		param4.addRule(RelativeLayout.ALIGN_BOTTOM, mong.getId());
		relativelayout.addView(chun, param4);
		
		setContentView(relativelayout);
	} 
	
	
}
